/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.maestros;

import DAO.ParametroDAO;
import Model.Empleado;
import Model.Parametro;
import Model.Perfil;
import Model.Turno;
import Presenter.EmpleadoPresenter;
import Presenter.EnvioPedidoPresenter;
import Presenter.PerfilPresenter;
import Presenter.TurnoPresenter;
import Principals.Validadores;
import View.components.Index;
import java.util.List;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;

/**
 *
 * @author walter
 */
public class Frm_ModificarEmpleado extends javax.swing.JDesktopPane {

    /**
     * Creates new form Frm_BuscarEmpleado
     */
    Empleado e = new Empleado();
    Validadores val = new Validadores();

    public Frm_ModificarEmpleado(int idEmpleado) {
        initComponents();
        EnvioPedidoPresenter.actualizarEnvioPedido();
        val.desactivarAccionPegar(txtApellidoMaterno);
        val.desactivarAccionPegar(txtApellidoPaterno);
        val.desactivarAccionPegar(txtNombre);
        val.desactivarAccionPegar(txtNroDocId);
        val.desactivarAccionPegar(txtTelefono);
        val.desactivarAccionPegar(txtNroBrevete);
        val.desactivarAccionPegar(txtDireccion);
        val.desactivarAccionPegar(txtCorreoElectronico);
        
        // Combo de perfiles
        List<Perfil> lstPerfil = PerfilPresenter.listPerfil();
        for (Perfil p : lstPerfil) {
            cbxPerfil.addItem(p);
        }
        // Combo de turnos
        List<Turno> lstTurno = TurnoPresenter.listTurno();
        for (Turno t : lstTurno) {
            cbxTurno.addItem(t);
        }
        // Combo de tipo de vehiculo
        List<Parametro> lstTipoVehiculo = ParametroDAO.getTipoVehiculos();
        for (Parametro p : lstTipoVehiculo) {
            cbxTipoVehiculo.addItem(p);
        }
        //Activar campos de conductor
        activarCamposConductor(false);

        e = EmpleadoPresenter.cargarEmpleado(idEmpleado);

        txtApellidoMaterno.setText(e.getApellidoMaterno());
        txtApellidoPaterno.setText(e.getApellidoPaterno());
        txtCorreoElectronico.setText(e.getCorreo());
        txtDireccion.setText(e.getDireccion());
        txtNombre.setText(e.getNombres());
        txtNroDocId.setText(e.getNroDocumento());
        txtTelefono.setText(e.getTelefono());
        cbxTurno.setSelectedItem(e.getTurno());
        cbxPerfil.setSelectedItem(e.getUsuario().getPerfil());

        if (cbxPerfil.getSelectedItem().toString().equals("Conductor")) {

            //Carga de campos de conductor
            txtNroBrevete.setText(e.getNroBrevete());
            cbxTipoVehiculo.setSelectedItem(e.getTipoVehiculo());
            activarCamposConductor(true);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar2 = new javax.swing.JToolBar();
        btnToolNuevo = new javax.swing.JButton();
        btnToolModificar = new javax.swing.JButton();
        btnToolAlmacenar = new javax.swing.JButton();
        btnToolEliminar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnToolLimpar = new javax.swing.JButton();
        btnToolBuscar = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        btnToolCancelar = new javax.swing.JButton();
        pnlModificarEmpleado = new javax.swing.JPanel();
        lblApellidoPaterno = new javax.swing.JLabel();
        txtApellidoPaterno = new javax.swing.JTextField();
        lblNombre = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        lblApellidoMaterno = new javax.swing.JLabel();
        txtApellidoMaterno = new javax.swing.JTextField();
        lblDocIdentidad = new javax.swing.JLabel();
        txtNroDocId = new javax.swing.JTextField();
        lblTelefono = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        lblCorreoElectronico = new javax.swing.JLabel();
        lblDireccion = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        lblPerfil = new javax.swing.JLabel();
        lblHorarioTrabajo = new javax.swing.JLabel();
        cbxTurno = new javax.swing.JComboBox();
        lblTipoVehiculo = new javax.swing.JLabel();
        cbxTipoVehiculo = new javax.swing.JComboBox();
        cbxPerfil = new javax.swing.JComboBox();
        txtCorreoElectronico = new javax.swing.JTextField();
        lblNroBrevete = new javax.swing.JLabel();
        txtNroBrevete = new javax.swing.JTextField();

        setPreferredSize(new java.awt.Dimension(665, 439));

        jToolBar2.setFloatable(false);
        jToolBar2.setBorderPainted(false);

        btnToolNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Nuevo.png"))); // NOI18N
        btnToolNuevo.setEnabled(false);
        btnToolNuevo.setFocusable(false);
        btnToolNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolNuevoActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolNuevo);

        btnToolModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Editar.png"))); // NOI18N
        btnToolModificar.setEnabled(false);
        btnToolModificar.setFocusable(false);
        btnToolModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolModificarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolModificar);

        btnToolAlmacenar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Guardar.png"))); // NOI18N
        btnToolAlmacenar.setFocusable(false);
        btnToolAlmacenar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolAlmacenar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolAlmacenar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolAlmacenarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolAlmacenar);

        btnToolEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Eliminar.png"))); // NOI18N
        btnToolEliminar.setEnabled(false);
        btnToolEliminar.setFocusable(false);
        btnToolEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolEliminarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolEliminar);
        jToolBar2.add(jSeparator3);

        btnToolLimpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Limpiar.png"))); // NOI18N
        btnToolLimpar.setEnabled(false);
        btnToolLimpar.setFocusable(false);
        btnToolLimpar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolLimpar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(btnToolLimpar);

        btnToolBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Buscar.png"))); // NOI18N
        btnToolBuscar.setFocusable(false);
        btnToolBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolBuscarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolBuscar);
        jToolBar2.add(jSeparator4);

        btnToolCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Cancelar.png"))); // NOI18N
        btnToolCancelar.setToolTipText("");
        btnToolCancelar.setFocusable(false);
        btnToolCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolCancelarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolCancelar);

        pnlModificarEmpleado.setBorder(javax.swing.BorderFactory.createTitledBorder("Modifcar datos de empleado"));
        pnlModificarEmpleado.setPreferredSize(new java.awt.Dimension(616, 439));

        lblApellidoPaterno.setText("Apellido Paterno*:");

        txtApellidoPaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApellidoPaternoKeyTyped(evt);
            }
        });

        lblNombre.setText("Nombres*:");

        txtNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombreKeyTyped(evt);
            }
        });

        lblApellidoMaterno.setText("Apellido Materno*:");

        txtApellidoMaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApellidoMaternoKeyTyped(evt);
            }
        });

        lblDocIdentidad.setText("Doc. de Identidad*:");

        txtNroDocId.setEnabled(false);
        txtNroDocId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNroDocIdKeyTyped(evt);
            }
        });

        lblTelefono.setText("Teléfono*:");

        txtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyTyped(evt);
            }
        });

        lblCorreoElectronico.setText("Correo electrónico*:");

        lblDireccion.setText("Dirección*:");

        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDireccionKeyTyped(evt);
            }
        });

        lblPerfil.setText("Perfil*:");

        lblHorarioTrabajo.setText("Turno*:");

        lblTipoVehiculo.setText("Tipo de vehículo*:");

        cbxPerfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxPerfilActionPerformed(evt);
            }
        });

        txtCorreoElectronico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtCorreoElectronicoKeyTyped(evt);
            }
        });

        lblNroBrevete.setText("Nro. de brevete*:");

        txtNroBrevete.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNroBreveteKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout pnlModificarEmpleadoLayout = new javax.swing.GroupLayout(pnlModificarEmpleado);
        pnlModificarEmpleado.setLayout(pnlModificarEmpleadoLayout);
        pnlModificarEmpleadoLayout.setHorizontalGroup(
            pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblApellidoPaterno)
                    .addComponent(lblDireccion)
                    .addComponent(lblNombre)
                    .addComponent(lblPerfil)
                    .addComponent(lblTipoVehiculo)
                    .addComponent(lblApellidoMaterno))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                        .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(txtApellidoMaterno, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE))
                            .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbxPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(47, 47, 47)
                        .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblTelefono)
                                    .addComponent(lblDocIdentidad))
                                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                                        .addGap(21, 21, 21)
                                        .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(txtNroDocId, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblCorreoElectronico)
                                    .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                                        .addGap(2, 2, 2)
                                        .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblNroBrevete)
                                            .addComponent(lblHorarioTrabajo))))
                                .addGap(18, 18, 18)
                                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(txtCorreoElectronico, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbxTurno, javax.swing.GroupLayout.Alignment.LEADING, 0, 144, Short.MAX_VALUE)
                                    .addComponent(txtNroBrevete, javax.swing.GroupLayout.Alignment.LEADING)))))
                    .addComponent(cbxTipoVehiculo, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDireccion))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        pnlModificarEmpleadoLayout.setVerticalGroup(
            pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlModificarEmpleadoLayout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblApellidoMaterno)
                            .addComponent(txtApellidoMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblTelefono)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblApellidoPaterno)
                        .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblDocIdentidad)
                        .addComponent(txtNroDocId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCorreoElectronico)
                    .addComponent(lblNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCorreoElectronico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDireccion)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblHorarioTrabajo)
                    .addComponent(cbxTurno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbxPerfil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPerfil))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlModificarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblTipoVehiculo)
                        .addComponent(cbxTipoVehiculo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblNroBrevete))
                    .addComponent(txtNroBrevete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(130, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlModificarEmpleado, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 645, Short.MAX_VALUE)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pnlModificarEmpleado, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE)
                .addContainerGap())
        );

        pnlModificarEmpleado.getAccessibleContext().setAccessibleName("ModificarEmpleado");
    }// </editor-fold>//GEN-END:initComponents

    private void cambiarVista(JDesktopPane panel) {
        ((Index) (this.getTopLevelAncestor())).changeDesktopPane(panel);
    }

    private void btnToolNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolNuevoActionPerformed
        cambiarVista(new Frm_RegistrarEmpleado()); // <---------------------------- ESTO SE DEBE CAMBIAR
    }//GEN-LAST:event_btnToolNuevoActionPerformed

    private void btnToolModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolModificarActionPerformed
    }//GEN-LAST:event_btnToolModificarActionPerformed

    private void btnToolBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolBuscarActionPerformed
        cambiarVista(new Frm_BuscarEmpleado());
    }//GEN-LAST:event_btnToolBuscarActionPerformed

    private void btnToolEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolEliminarActionPerformed
        cambiarVista(new Frm_EliminarEmpleado());
    }//GEN-LAST:event_btnToolEliminarActionPerformed

    private void btnToolCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolCancelarActionPerformed
        cambiarVista(new Frm_BuscarEmpleado());
    }//GEN-LAST:event_btnToolCancelarActionPerformed

    private void btnToolAlmacenarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolAlmacenarActionPerformed
        String apPat = txtApellidoPaterno.getText();
        String apMat = txtApellidoMaterno.getText();
        String nombres = txtNombre.getText();
        String nroDoc = txtNroDocId.getText();
        String correo = txtCorreoElectronico.getText();
        String telefono = txtTelefono.getText();
        String direccion = txtDireccion.getText();
        Turno turno = (Turno) cbxTurno.getSelectedItem();
        Parametro tipoVehiculo = (Parametro) cbxTipoVehiculo.getSelectedItem();
        String nroBrevete = txtNroBrevete.getText();
        Perfil perfil = (Perfil) cbxPerfil.getSelectedItem();

        String mensaje_error = "";
        boolean error=false;
        //Campos obligatorios estén llenos
        if ("".equals(apPat) || "".equals(apMat) || "".equals(nombres) || "".equals(nroDoc)
                || "".equals(correo) || "".equals(telefono) || "".equals(direccion) 
                || (perfil.getNombre().equals("Conductor") && nroBrevete.isEmpty())){    
            mensaje_error="Debe completar todos los campos obligatorios.";
            error=true;
        }
        
        //DNI válido
        if (!nroDoc.isEmpty() && nroDoc.length() != 8){
            if (error) mensaje_error=mensaje_error.concat("\n");            
            mensaje_error=mensaje_error.concat("Debe ingresar un número de documento válido.");
            error=true;
        }
        
        //telefono válido
        if (!telefono.isEmpty() && telefono.length() < 7){
            if (error) mensaje_error=mensaje_error.concat("\n");            
            mensaje_error=mensaje_error.concat("Debe ingresar un número de teléfono válido.");
            error=true;
        }
        
        //Correo electrónico válido
        if (!correo.isEmpty() && !val.validaEmail(correo)) {
            if (error) mensaje_error=mensaje_error.concat("\n");            
            mensaje_error=mensaje_error.concat("Debe ingresar un correo válido.");
            error=true;
        }
        
        //Brevete válido
        if (perfil.getNombre().equals("Conductor") && nroBrevete.length() != 9){
            if (error) mensaje_error=mensaje_error.concat("\n");            
            mensaje_error=mensaje_error.concat("Debe ingresar un número de brevete válido.");
            error=true;
        }
        
        if (!error) {
            EmpleadoPresenter.modificarEmpleado(e, apPat, apMat, nombres, nroDoc, correo, telefono, direccion, turno, tipoVehiculo, perfil, nroBrevete);
            JOptionPane.showMessageDialog(this, "Se actualizó los datos de " + nombres + " " + apPat);
            cambiarVista(new Frm_BuscarEmpleado());            
        } else {
            JOptionPane.showMessageDialog(this, mensaje_error);
        }
    }//GEN-LAST:event_btnToolAlmacenarActionPerformed

    private void cbxPerfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxPerfilActionPerformed
        if (cbxPerfil.getSelectedItem().toString().equals("Conductor")) {
            activarCamposConductor(true);
        } else {
            activarCamposConductor(false);
        }
    }//GEN-LAST:event_cbxPerfilActionPerformed

    private void txtApellidoPaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoPaternoKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtApellidoPaterno.getText());
    }//GEN-LAST:event_txtApellidoPaternoKeyTyped

    private void txtApellidoMaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoMaternoKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtApellidoMaterno.getText());
    }//GEN-LAST:event_txtApellidoMaternoKeyTyped

    private void txtNombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtNombre.getText());
    }//GEN-LAST:event_txtNombreKeyTyped

    private void txtNroBreveteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNroBreveteKeyTyped
        val.validaSoloNumerosLetras(evt);
        val.validaMaxSize(evt, 9, txtNroBrevete.getText());
    }//GEN-LAST:event_txtNroBreveteKeyTyped

    private void txtNroDocIdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNroDocIdKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 8, txtNroDocId.getText());
    }//GEN-LAST:event_txtNroDocIdKeyTyped

    private void txtTelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 10, txtTelefono.getText());
    }//GEN-LAST:event_txtTelefonoKeyTyped

    private void txtCorreoElectronicoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCorreoElectronicoKeyTyped
        val.validaCaracteresEmail(evt);
        val.validaMaxSize(evt, 40, txtCorreoElectronico.getText());
    }//GEN-LAST:event_txtCorreoElectronicoKeyTyped

    private void txtDireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyTyped
        val.validaCaracteresDirec(evt);
        val.validaMaxSize(evt, 40, txtDireccion.getText());
    }//GEN-LAST:event_txtDireccionKeyTyped
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnToolAlmacenar;
    private javax.swing.JButton btnToolBuscar;
    private javax.swing.JButton btnToolCancelar;
    private javax.swing.JButton btnToolEliminar;
    private javax.swing.JButton btnToolLimpar;
    private javax.swing.JButton btnToolModificar;
    private javax.swing.JButton btnToolNuevo;
    private javax.swing.JComboBox cbxPerfil;
    private javax.swing.JComboBox cbxTipoVehiculo;
    private javax.swing.JComboBox cbxTurno;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JLabel lblApellidoMaterno;
    private javax.swing.JLabel lblApellidoPaterno;
    private javax.swing.JLabel lblCorreoElectronico;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblDocIdentidad;
    private javax.swing.JLabel lblHorarioTrabajo;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblNroBrevete;
    private javax.swing.JLabel lblPerfil;
    private javax.swing.JLabel lblTelefono;
    private javax.swing.JLabel lblTipoVehiculo;
    private javax.swing.JPanel pnlModificarEmpleado;
    private javax.swing.JTextField txtApellidoMaterno;
    private javax.swing.JTextField txtApellidoPaterno;
    private javax.swing.JTextField txtCorreoElectronico;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtNroBrevete;
    private javax.swing.JTextField txtNroDocId;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables

    private void activarCamposConductor(boolean activo) {
        lblTipoVehiculo.setEnabled(activo);
        cbxTipoVehiculo.setEnabled(activo);
        lblNroBrevete.setEnabled(activo);
        txtNroBrevete.setEnabled(activo);
    }
}
